function cardClick(ele) {
    console.log(ele, "-------nav");
    window.location.href=ele.ele.children[0].href;
}
// 弹窗cookie逻辑请自行清除处理
function navRecommendClick(ele) {
    console.log(ele, "-------navRecommendClick");
    document.getElementById("layer").style.display = "grid";
    iptv.isMoveScroll = false; //超出可视范围自动移动禁止移动
    iptv.focusGroup("layer");
}
// 隐藏弹窗
function hiddenDiv() {
    document.getElementById("layer").style.display = "none";
    iptv.isMoveScroll = true; //打开超出可视范围自动移动
    iptv.focusGroup("column", 12); //指定聚焦组内元素的index
}
//展示超出可视范围自动移动弹窗
function MoveScrollClick(ele) {
    console.log(ele, "-------navRecommendClick");
    document.getElementById("MoveScroll").style.display = "block";
    iptv.focusGroup("MoveScroll");
}
//隐藏超出可视范围自动移动弹窗
function hiddenMoveScroll() {
    document.getElementById("MoveScroll").style.display = "none";
    iptv.focusGroup("column", 'move-id'); //指定聚焦组内元素的id
}
//自定义聚焦
function changeImg(ele) {
    console.log(ele, ele.ele, "------------自定义聚焦");
    ele.ele.classList.add("focusing");
}

//自定义失焦
function blurImg(ele) {
    console.log(ele, ele.ele, "------------自定义失焦");
    ele.ele.classList.remove("focusing");
}
var column = [1, 3, 6, 4, 5, 6, 7, 8, 9, 10, 11, 99];
//自定义左翻页
function left(e) {
    console.log(e);
    home._trun("left");
}
//自定义右翻页
function right(e) {
    console.log(e);
    home._trun("right");
}

var home = {
    _data: column,
    _pages: 0, // 当前页码
    _pagesCount: 6, // 每页元素数量
    _trun: function (dir) { // 翻页
        //this._progress(); //渲染页码
        var videoData = column;
        var pages = parseInt(videoData.length / this._pagesCount);
        if(videoData.length % this._pagesCount == 0) {
        } else {
            pages = pages + 1;
        }
        console.log(this._pages, pages);
        if (dir == "right" && this._pages < pages - 1) {
            this._pages++;
            iptv.onFocus(iptv._groupList[iptv._nowEle.groupName].foucsList[0])
        } else if (dir == "left" && this._pages > 0) {
            this._pages--;
        }
        var length = this._length();
        for (var i = 0; i < length; i++) {
            var divEle = iptv._groupList[iptv._nowEle.groupName].foucsList[i].ele;
            var pEle = divEle.children[0];
            var gameName = videoData[(this._pages * this._pagesCount) + i];
            console.log(i, divEle.children, gameName);
            pEle.innerHTML = gameName;
            var x = length;
            while (x < this._pagesCount) {
                iptv._groupList[iptv._nowEle.groupName].foucsList[x].ele.style.display = "none";
                x++;
            }
            divEle.style.display = "block";
        }
    },
    _progress: function () {
        var videoData = this._data;
        var pages = videoData.length % this._pagesCount == 0 ? parseInt(videoData.length / this
            ._pagesCount) : parseInt(videoData.length / this._pagesCount) + 1;
        if (pages == 0) {
            evm.hidden("progress");
        } else {
            evm.visible("progress");
            evm.$("progress").innerHTML = "" + parseInt(this._pages + 1) + " / " + pages;
        }
    },
    //本页长度
    _length: function () {
        var videoData = column;
        var length;
        if (videoData.length > 0) {
            length = (videoData.length % this._pagesCount == 0) || (videoData.length / ((this._pages + 1) *
                this._pagesCount) >= 1) ? this._pagesCount : videoData.length % this._pagesCount;
        } else {
            length = 0;
        }
        return length;
    },
    _enter: function (ele) {
        // console.log(home._data, home._pages, home._pagesCount, ele.focusIndex);
        var gameName = home._data[(home._pages * home._pagesCount) + ele.focusIndex];
        console.log(gameName, "-------------gameName");
        console.log(ele);
    },
};
var iptv = new iptvFocus({
    hasLayer: true, //是否有弹窗 有弹窗则必须设置group
    focusClassScale: 1.1,
    visualMargin: 20,
});